﻿using System.Windows.Controls.Ribbon;

namespace Hopscotch.Application.Shell
{
    /// <summary>
    /// Interaction logic for ShellWindow.xaml
    /// </summary>	
    public partial class ShellWindow : RibbonWindow
    {
        private readonly ShellViewModel shellViewModel;

        public ShellWindow()
        {
            InitializeComponent();
        }

        public ShellWindow(ShellViewModel shellViewModel)
            :this()
        {
            this.shellViewModel = shellViewModel;
            this.DataContext = shellViewModel;

            this.Loaded += ShellWindow_Loaded;
        }

        void ShellWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            //Windows will sometimes lose the focus after closing the login window, reactive after it's loaded
            this.Activate();
        }

        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            base.OnClosing(e);

            //Tell the ShellViewModel we are closing in case it needs to shutdown the app
            shellViewModel.Close();
        }
    
    }
}
